﻿// // ******************************************************************
// //       /\ /|       @file       UserService.cs
// //       \ V/        @brief      await29
// //       | "")       @author     Await, 285283010@qq.com
// //       /  |
// //      /  \\        @Modified   2024-11-20 16:11
// //    *(__\_\        @Copyright  Copyright (c) , 2024-11-20 14:11 Await
// // ******************************************************************

using AutomaticSubtitles.Contracts.Dto;
using AutomaticSubtitles.Contracts.Vo;
using AutomaticSubtitles.Service.Application.User.Commands;
using AutomaticSubtitles.Service.Application.User.Queries;

namespace AutomaticSubtitles.Service.Services;

/// <summary>
/// 用户服务
/// </summary>
public class UserService : BaseService<UserService>
{
 
    [EndpointDescription("用户登录")]
    [EndpointName("用户登录")]
    [EndpointSummary("用户登录")]
    public async Task<ResponseModel<UserTokenDto>> LoginAsync(LoginVo data)
    {
        var createLoginTokenCommand = new CreateLoginTokenCommand(data);
        await PublishAsync(createLoginTokenCommand);
        return createLoginTokenCommand.Result.CreateResult();
    }

    [EndpointDescription("获取用户信息")]
    [EndpointName("获取用户信息")]
    [EndpointSummary("获取用户信息")]
    [Authorize]
    public async Task<ResponseModel<UserLoginDto>> GetUserInfo()
    {
        var createLoginTokenCommand = new GetUserDataQuery(GetUserId());
        await PublishAsync(createLoginTokenCommand);
        return createLoginTokenCommand.Result.CreateResult();
    }
}